<?php

namespace catchAdmin\pc\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\pc\model\Feedback as FeedbackModel;
use think\Response;

class Feedback extends CatchController
{

    protected $feedbackModel;


    /**
     *
     * @time 2025/08/27 17:07
     * @param FeedbackModel $feedbackModel
     * @return mixed
     */
    public function __construct(FeedbackModel $feedbackModel)
    {
        $this->feedbackModel = $feedbackModel;
    }


    /**
     *
     * @time 2025/08/27 17:07
     * @return Response
     */
    public function index(): Response
    {
        return CatchResponse::paginate($this->feedbackModel->getList());
    }


    /**
     *
     * @time 2025/08/27 17:07
     * @param Request $request
     * @return Response
     */
    public function save(Request $request): Response
    {
        return CatchResponse::success($this->feedbackModel->storeBy($request->post()));
    }


    /**
     *
     * @time 2025/08/27 17:07
     * @param $id
     * @return Response
     */
    public function read($id): Response
    {
        return CatchResponse::success($this->feedbackModel->findBy($id));
    }


    /**
     *
     * @time 2025/08/27 17:07
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request): Response
    {
        return CatchResponse::success($this->feedbackModel->updateBy($id, $request->post()));
    }


    /**
     *
     * @time 2025/08/27 17:07
     * @param $id
     * @return Response
     */
    public function delete($id): Response
    {
        return CatchResponse::success($this->feedbackModel->deleteBy($id));
    }
}
